package com.heiye.relation.biz.controller;

import com.heiye.framework.biz.operationlog.aspect.ApiOperationLog;
import com.heiye.framework.common.response.Response;
import com.heiye.relation.api.dto.FindQuizFansTop3ByIdsReqDTO;
import com.heiye.relation.api.dto.FindQuizFansTop3ByIdsRspDTO;
import com.heiye.relation.biz.model.vo.FindQuizIsFollowReqVO;
import com.heiye.relation.biz.model.vo.FindQuizIsFollowRspVO;
import com.heiye.relation.biz.model.vo.FollowQuizReqVO;
import com.heiye.relation.biz.model.vo.UnfollowQuizReqVO;
import com.heiye.relation.biz.service.QuizRelationService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: heiye
 * @date: 2025/04/15 下午5:05
 * @version: v1.0.0
 * @description: 提问关系业务
 */
@RestController
@RequestMapping("/quiz")
public class QuizRelationController {
    @Resource
    private QuizRelationService quizRelationService;

    /**
     * 关注问题
     *
     * @param followQuizReqVO
     * @return
     */
    @PostMapping("/follow")
    @ApiOperationLog(description = "关注问题")
    public Response<?> follow(@Validated @RequestBody FollowQuizReqVO followQuizReqVO) {
        return quizRelationService.follow(followQuizReqVO);
    }

    /**
     * 取关问题
     *
     * @param unfollowQuizReqVO
     * @return
     */
    @PostMapping("/unfollow")
    @ApiOperationLog(description = "取关问题")
    public Response<?> unfollow(@Validated @RequestBody UnfollowQuizReqVO unfollowQuizReqVO) {
        return quizRelationService.unfollow(unfollowQuizReqVO);
    }

    /**
     * 查询问题是否被关注
     *
     * @param findQuizIsFollowReqVO
     * @return
     */
    @PostMapping("/findQuizIsFollow")
    @ApiOperationLog(description = "查询问题是否被关注")
    public Response<FindQuizIsFollowRspVO> findQuizIsFollow(@Validated @RequestBody FindQuizIsFollowReqVO findQuizIsFollowReqVO) {
        return quizRelationService.FindQuizIsFollow(findQuizIsFollowReqVO);
    }

    // ===================================== 对其他服务提供的接口 =====================================

    /**
     * 查询问题粉丝列表前3位
     *
     * @param findQuizFansThreeByIdsReqDTO
     * @return
     */
    @PostMapping("/findQuizFansTop3ByIds")
    @ApiOperationLog(description = "查询问题粉丝列表前3位")
    public Response<FindQuizFansTop3ByIdsRspDTO> findQuizFansTop3ByIds(@Validated @RequestBody FindQuizFansTop3ByIdsReqDTO findQuizFansThreeByIdsReqDTO) {
        return quizRelationService.findQuizFansTop3ByIds(findQuizFansThreeByIdsReqDTO);
    }
}
